package com.bgds.sys.rbac.serviceimpl;

import com.bgds.sys.common.base.BaseDao;
import com.bgds.sys.rbac.dao.RolePermissionDao;
import com.bgds.sys.rbac.domain.RolePermission;
import com.bgds.sys.rbac.service.RolePermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * 角色权限业务实现类
 * @author lj
 */
@Slf4j
@Service
@Transactional(rollbackOn = Exception.class)
public class RolePermissionServiceImpl implements RolePermissionService {

    @Autowired
    private RolePermissionDao rolePermissionDao;
    @Override
    public BaseDao<RolePermission, Long> getRepository() {
        return rolePermissionDao;
    }

    /**
     * 通过角色ID删除相关权限
     * @param roleId
     */
    @Override
    public Integer deleteByRoleId(Long roleId){
        return rolePermissionDao.deleteByRoleId(roleId);
    }
    @Override
    public List<RolePermission> findByRoleId(Long roleId){
        return rolePermissionDao.findByRoleId(roleId);
    }
}
